package com.hyt.it.ogt.ykcj.common.enums.zs;

import lombok.Getter;

import java.util.Arrays;

/**
 * 港澳台性别
 * 性别(男M,女F,未知N)
 */
@Getter
public enum GATSexEnums {

    MAN("M", "男"),
    WOMAN("F", "女"),
    ;

    private final String code;
    private final String type;
    private final String desc;

    GATSexEnums(String type, String desc) {
        this.code = name();
        this.type = type;
        this.desc = desc;
    }

    public static String[] allDesc() {
        return Arrays.stream(values())
                .map(GATSexEnums::getDesc)
                .distinct()
                .toArray(String[]::new);
    }

    public static String getTypeByDesc(String desc) {
        for (GATSexEnums sexEnums : values()) {
            if (sexEnums.getDesc().equals(desc)) {
                return sexEnums.getType();
            }
        }
        return null;
    }

    public static String getDescByType(String type) {
        for (GATSexEnums sexEnums : values()) {
            if (sexEnums.getType().equals(type)) {
                return sexEnums.getDesc();
            }
        }
        return null;
    }
}
